package com.bailian.app.config;

import com.bailian.app.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * App Web配置
 * 
 * @author bailian
 */
@Configuration
public class AppWebConfig implements WebMvcConfigurer {

    @Autowired
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/app/api/**")
                .excludePathPatterns(
                        // 微信认证相关 - 不需要认证
                        "/app/api/auth/wx/login",
                        "/app/api/auth/wx/bindPhone",
                        "/app/api/auth/wx/decryptPhone",
                        // 注意：refreshToken需要认证，所以不排除
                        
                        // 通用功能 - 不需要认证
                        "/app/api/common/banner/list",
                        "/app/api/common/search",
                        "/app/api/common/upload",
                        
                        // 仓库相关 - 不需要认证
                        "/app/api/warehouse/types",
                        "/app/api/warehouse/tags",
                        "/app/api/warehouse/list",
                        "/app/api/warehouse/*",
                        
                        // 园区相关 - 不需要认证
                        "/app/api/park/list",
                        "/app/api/park/areaList",
                        "/app/api/park/*",

                        // 资讯相关 - 不需要认证
                        "/app/api/news/list",
                        "/app/api/news/category",
                        "/app/api/news/*"

                        // 收藏相关 - 不需要认证
                        // "/app/api/favorite/list",
                        // "/app/api/favorite/check",
                        // "/app/api/favorite/add",
                        // "/app/api/favorite/cancel"
                );
    }
} 